package com.kehutong.admin.entity;

import org.coraframework.orm.annotation.Column;
import org.coraframework.orm.annotation.Table;

/**
 * 菜单
 * @author liuzhen (liuxing521a@163.com)
 * @createTime 2019年4月16日下午5:53:14
 */
@Table("sys_menu")
public class Menu extends TreeResource<Menu> {

	private static final long serialVersionUID = 2923716357230913209L;

	protected Menu(String id){
		super(id);
		this.sort = 30;
	}
	
	@Column(comment="链接")
	private String href;

	@Column(comment="目标（ mainFrame、_blank、_self、_parent、_top）")
	private String target;

	@Column(comment="图标")
	private String icon;

	@Column(defValue = "NOT NULL", comment="排序")
	private Integer sort;
	
	@Column(comment="权限标识")
	private String permission;
	
	@Column(comment="是否显示")
	private Integer show;

	@Column(comment="应用标识")
	private String identify;

	@Column(comment="应用前缀")
	private String active;

	@Column(comment="应用图标")
	private String fileId;

	@Column(comment="菜单类型")
	private String menuType;

	@Column(comment="应用类型")
	private String appType;

	@Column(comment = "跳转类型")
	private String redirectType;

	@Column(comment="应用地址")
	private String entry;
	
	@Column(length = 64, comment="备注")
	private String remarks;


	public String getHref() {
		return href;
	}

	public void setHref(String href) {
		this.href = href;
	}

	public String getTarget() {
		return target;
	}

	public void setTarget(String target) {
		this.target = target;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public Integer getSort() {
		return sort;
	}

	public void setSort(Integer sort) {
		this.sort = sort;
	}
	
	public String getPermission() {
		return permission;
	}

	public void setPermission(String permission) {
		this.permission = permission;
	}
	
	public Integer getShow() {
		return show;
	}

	public void setShow(Integer show) {
		this.show = show;
	}

	public String getRemarks() {
		return remarks;
	}

	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}

	public String getIdentify() {
		return identify;
	}

	public void setIdentify(String identify) {
		this.identify = identify;
	}

	public String getActive() {
		return active;
	}

	public void setActive(String active) {
		this.active = active;
	}

	public String getFileId() {
		return fileId;
	}

	public void setFileId(String fileId) {
		this.fileId = fileId;
	}

	public String getMenuType() {
		return menuType;
	}

	public void setMenuType(String menuType) {
		this.menuType = menuType;
	}

	public String getAppType() {
		return appType;
	}

	public void setAppType(String appType) {
		this.appType = appType;
	}

	public String getEntry() {
		return entry;
	}

	public void setEntry(String entry) {
		this.entry = entry;
	}

	public String getRedirectType() {
		return redirectType;
	}

	public void setRedirectType(String redirectType) {
		this.redirectType = redirectType;
	}

	@Override
	public int compareTo(Menu o) {
		if (sort > o.sort) {
			return -1;
		}
		
		if (sort < o.sort) {
			return 1;
		}
		
		return 0;
	}

	@Override
	public boolean sortAble() {
		return true;
	}

	public boolean showAll(boolean showAll) {
		if (showAll) {
			return true;
		}
		if (show == null) {
			return true;
		}

		return show == 1;
	}
	
	
}